package cn.bytets.rpc.api.context;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 上下文,主要是为缓存数据,这里只做测试
 */
public class RpcAppContext {

    private  Map<String,Object> beanMap = new ConcurrentHashMap<>(16);

    private RpcAppContext(){}

    public void addBean(String name,Object value){
        beanMap.put(name,value);
    }

    public Object getBean(String name){
       return beanMap.get(name);
    }
    public static RpcAppContext getInstance(){
        return RpcAppContextInstant.getApp();
    }
    private static class RpcAppContextInstant{

        private static RpcAppContext app = new RpcAppContext();

        public static RpcAppContext getApp(){
            return app;
        }
    }

    public String getInterfaceName(Map<String,String> map){
        return map.get("interfaceName");
    }
}
